import java.util.ArrayList;
import java.util.HashSet;
import java.util.Hashtable;


public class ErrorHandler extends Hashtable<Integer, String> {
	private final String newline = System.getProperty("line.separator");
	private ArrayList<Integer> usedErrors = new ArrayList<Integer>();
	private int errorcount = 0;
	
	public ErrorHandler(){
		this.put(1, "RECORD CONTAINS INVALID CHARACTERS");
		this.put(2, "OBJECT FILE RECORDS MUST CONTAIN COLONS TO SEPARATE FIELDS");
		this.put(3, "INVALID RECORD TYPE, MUST EITHER BE A HEADER (H), TEXT (T), OR END (E) RECORD");
		this.put(4, "ASSEMBLER ASSIGNED LOAD PAGE IS INVALID, MUST BE IN RANGE OF 0-3");
		this.put(5, "LOAD PAGE CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(6, "ASSEMBLER ASSIGNED LOAD ADDRESS IS INVALID, MUST BE IN RANGE OF 0-4095");
		this.put(7, "LOAD ADDRESS CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(8, "INVALID MODULE LENGTH, MUST BE IN RANGE 0-16383");
		this.put(9, "MODULE LENGTH CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(10, "EXECUTION START ADDRESS EXCEEDS THE PROGRAM LENGTH");
		this.put(11, "EXECUTION START ADDRESS CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(12, "PROGRAM NAMES MUST MATCH IN THE HEADER RECORD OF AN OBJECT FILE");
		this.put(13, "WARNING: OBJECT FILE SHOULD HAVE BEEN PRODUCED BY A FICKELL ASSEMBLER");
		this.put(14, "PROGRAM NAME HAS ALREADY BEEN DEFINED IN THE SYMBOL TABLE");
		this.put(15, "PROGRAM ASSIGNED PAGE VALUE IS INVALID, MUST BE IN RANGE OF 0-3");
		this.put(16, "PROGRAM ASSIGNED PAGE VALUE CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(17, "PROGRAM ASSIGNED LOCATION VALUE IS INVALID, MUST BE IN RANGE OF 0-4095");
		this.put(18, "PROGRAM ASSIGNED LOCATION VALUE CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(19, "INSTRUCTION/DATA WORD CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(20, "INVALID STATUS FLAG USED");
		this.put(21, "INVALID NUMBER OF M ADJUSTMENTS USED");
		this.put(22, "TEXT RECORD PROGRAM NAME MUST MATCH CURRENT MODULES PROGRAM NAME");
		this.put(23, "TEXT RECORDS MUST CONTAIN EXACTLY 6 FIELDS");
		this.put(24, "LABEL HAS INVALID SYNTAX");
		this.put(25, "ENTRY NAME IS ALREADY DEFINED IN THE SYMBOL TABLE");
		this.put(26, "PAGE VALUE IS INVALID, MUST BE IN THE RANGE OF 0-3");
		this.put(27, "PAGE VALUE CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(28, "LOCATION VALUE IS INVALID, MUST BE IN RANGE OF 0-4095");
		this.put(29, "LOCATION VALUE CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(30, "LINKING RECORD PROGRAM NAME MUST MATCH CURRENT MODULE'S PROGRAM NAME");
		this.put(31, "LINKING RECORDS MUST CONTAIN EXACTLY 4 FIELDS");		
		this.put(32, "PAGE VALUE IS INVALID, MUST BE IN RANGE OF 0-3");
		this.put(33, "PAGE VALUE CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(34, "LOCATION VALUE IS INVALID, MUST BE IN RANGE OF 0-16383");
		this.put(35, "LOCATION VALUE CONTAINS INVALID HEXADECIMAL SYNTAX");		
		this.put(36, "THE NUMBER OF ADJUSTMENTS DOES NOT MATCH THE ADJUSTMENT VALUE");
		this.put(37, "INVALID SIGN USED IN THE ADJUSTMENT SET, MUST EITHER BE + OR -");
		this.put(38, "LABEL NAME IN THE ADJUSTMENT SET IS INVALID, MUST BE 2-32 CHARACTERS AND NUMBERS IN LENGTH, AND MUST START WITH A LETTER");
		this.put(39, "MODIFICATION RECORD PROGRAM NAME MUST MATCH THE CURRENT MODULE'S PROGRAM NAME");		
		this.put(40, "HEADER RECORDS MUST CONTAIN EXACTLY 11 FIELDS");
		this.put(41, "MODIFICATION RECORDS MUST HAVE EXACTLY EITHER 6, 8, 10 OR 12 FIELDS");
		this.put(42, "THE VALUE OF TOTAL RECORDS IN THE END RECORD DOES NOT MATCH THE TOTAL RECORD COUNT");
		this.put(43, "THE VALUE OF TOTAL RECORDS CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(44, "THE VALUE OF TOTAL TEXT RECORDS IN THE END RECORD DOES NOT MATCH THE TEXT RECORD COUNT");
		this.put(45, "THE VALUE OF TOTAL TEXT RECORDS CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(46, "THE VALUE OF TOTAL MODIFICATION RECORDS IN THE END RECORD DOES NOT MATCH THE TEXT RECORD COUNT");
		this.put(47, "THE VALUE OF TOTAL MODIFICATION RECORDS CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(48, "THE VALUE OF TOTAL LINKING RECORDS IN THE END RECORD DOES NOT MATCH THE TEXT RECORD COUNT");
		this.put(49, "THE VALUE OF TOTAL LINKING RECORDS CONTAINS INVALID HEXADECIMAL SYNTAX");
		this.put(50, "END RECORDS MUST HAVE EXACTLY 6 FIELDS");		
		this.put(51, "PROGRAM NAME IS INVALID, MUST BE 2-32 CHARACTERS AND NUMBERS LONG AND MUST BEGIN WITH A LETTER");
		this.put(52, "LOCATION HEX VALUE MUST BE 6 HEX DIGITS IN LENGTH");
		this.put(53, "INSTRUCTION/DATA WORD MUST BE 8 HEX DIGITS IN LENGTH");
		this.put(54, "MODULE LENGTH VALUE MUST BE 4 HEX DIGITS IN LENGTH");
		this.put(55, "EXECUTION START VALUE MUST BE 4 HEX DIGITS IN LENGTH");
		this.put(56, "TOTAL NUMBER OF RECORDS IN THE END RECORD MUST BE 4 HEX DIGITS IN LENGTH");
		this.put(57, "TOTAL NUMBER OF LINKING RECORDS IN THE END RECORD MUST BE 4 HEX DIGITS IN LENGTH");
		this.put(58, "TOTAL NUMBER OF TEXT RECORDS IN THE END RECORD MUST BE 4 HEX DIGITS IN LENGTH");
		this.put(59, "TOTAL NUMBER OF MODIFICATION RECORDS IN THE END RECORD MUST BE 4 HEX DIGITS IN LENGTH");
		this.put(60, "NUMBER OF TEXT RECORDS EXCEED THE CURRENT MODULES LENGTH");
		this.put(61, "MAX NUMBER OF ENTRY SYMBOLS HAS BEEN REACHED, LABEL WILL BE IGNORED");
		this.put(62, "PASS 2: TEXT RECORD WITH NEEDED ADJUSTMENTS DOES NOT HAVE A CORRESPONDING MOD RECORD, LINE WILL BE REPLACED BY NOP");
		this.put(63, "Pass 2: RELOCATED S-FIELD IS OUT OF RANGE, MUST BE IN RANGE OF 0-4095. LINE WILL BE REPLACED BY NOP");
		this.put(64, "Pass 2: LOAD ADDRESS IS OUT OF PROGRAM RANGE. LINE WILL BE IGNORED");
		this.put(65, "Pass 2: LABEL USED FOR ADDRESS MODIFICATION IS NOT DEFINED. THE TEXT RECORD THAT CALLS THIS MODIFICATION WILL BE REPLACED BY NOP");
		this.put(66, "**FATAL** : THE FIRST RECORD OF THE OBJECT FILE MUST BE A VALID HEADER RECORD. LINKING/LOADING WILL BE STOPPED");
		this.put(67, "PROGRAM ASSIGNED LOCATION MUST BE 6 HEX DIGITS LONG");
		this.put(68, "**WARNING** OBJECT FILE RECORDS MAY NOT HAVE : AS THE LAST CHARACTER. THE ENDING : WILL BE IGNORED.");
		this.put(69, "THE VALUE OF ADJUSTMENTS REQUIRED MUST BE 1 HEX DIGIT IN LENGTH");
		this.put(70, "LOAD ADDRESS MUST BE 6 HEX DIGITS IN LENGTH");
		this.put(71, "ADJUSTMENT VALUE IN THE TEXT RECORD CONTAINS INVALID HEXADECIMAL SYNTAX");
		

	}

	public ArrayList<Integer> getUsedErrors(){
		return usedErrors;
	}
	
	public int getErrorCount(){
		return errorcount;
	}
	
	public void clearUsedErrors(){
		usedErrors.clear();
	}
	
	public void clearAllErrors(){
		usedErrors.clear();
		errorcount = 0;
	}
}
